<?php 
header("content-type:text/html;charset=utf-8");
$goods_id = $_POST['goods_id'];
$redis = new Redis();
$redis -> connect("127.0.0.1","6379");
// print_r($goods_id);die();
$pdo = new PDO("mysql:host=127.0.0.1;dbname=lx","root","root");
$sql = "select count from goods where id = $goods_id";
$res = $pdo->query($sql)->fetch();
for ($i=1; $i <= $res['count']; $i++) { 
	$redis->lpush("data".$goods_id,$i);
	
}
// print_r($res);die();
// if ($redis->lpop("data".$goods_id)) {
// 	$sql = "update goods set count = count-1 where id = $goods_id";
// 	$info = $pdo->exec($sql);
// 	// print_r($info);die();
// 	if ($info) {
// 		$data = array('code'=>1,"msg"=>"抢购成功");
// 	}
// }else{
// 		$data = array('code'=>0,"msg"=>"不好意思,没货了!");
// }
// 	echo json_encode($data);



 ?>